<jsp:include page="../template/header.jsp"></jsp:include>
	
	<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>

<script type="text/javascript">

	$(document).ready(function() {
		$.ajax({
			url: 'http://localhost:8080/FoodService/services/rest/restaurantes/listado',
			type: 'GET',
			success: function(data) {
				$.each(data, function(i, plato){
				
				if (data!=null) { 
					
					var edit = <%=request.getContextPath()%>+'/restaurante/ingresarEdit.htm?codigoPlato=' + plato.codigo;
					var delet = <%=request.getContextPath()%>+'/restaurante/delete.htm?codigoPlato=' + plato.codigo;
				
						$('#tBodyGrid').append(
						"<tr>" +
							'<td>' + plato.restaurant.codigo + '</td>' +
							'<td>' + plato.categoriaplato.codigo + '</td>' +
							'<td>' + plato.codigo + '</td>' + 
							'<td>' + plato.nombrePlato + '</td>' +
							'<td>' + plato.descripcion + '</td>' +
							'<td>' + plato.fechaPublicacion + '</td>' +
							'<td> <a class="btn btn-primary" href="'+ edit + '">Editar</a> </td>' +
							'<td> <a class="btn btn-primary" href="'+ delet + '">Eliminar</a> </td>' +																				
						"</tr>" 
						);
					 }
				});			
			},
			error: function(data) {
				alert("Error");
			}
		});
	 });
	 
</script>
<form class="form-horizontal" method="post">
<fieldset>

<legend>Listado de Restaurantes</legend>
          
<table class="table table-striped table-bordered table-condensed">
  <thead>
    <tr>
      	<th>Restaurant</th>
	    <th>Codigo categoria</th>
	    <th>Nombre</th><th>Descripcion</th>
	    <th>Ubicacion</th>
	    <th>Locales</th>
	    <th>Editar</th>
	    <th>Eliminar</th>
	    
    </tr>
  </thead>
  <tbody id="tBodyGrid">
  </tbody>
</table>
<div class="form-actions">
  <a class="btn btn-primary" href="<%=request.getContextPath()%>/plato/ingresarSave.htm" >Nuevo</a>
 </div>
</fieldset>
 
 </form>
 
<jsp:include page="../template/footer.jsp"></jsp:include>